package qj.tool.http;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class SimpleWebBrowser {
	public String get(String url) throws IOException {
		HttpURLConnection test = (HttpURLConnection) new URL(url)
				.openConnection();
		test.setRequestProperty("User-Agent",
				"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
		test.setRequestMethod("GET");

		
		
		BufferedReader in = new BufferedReader(new InputStreamReader(test
				.getInputStream()));

		// Read it ...
		StringBuffer sb = new StringBuffer();
		String inputLine;
		for (boolean firstLine = true ; (inputLine = in.readLine()) != null; firstLine=false) {
			if (!firstLine)
				sb.append("\n");
			
			sb.append(inputLine);
		}
		
		return sb.toString();
	}

	public static void main(String[] args) throws IOException {
//		Environment.setupHttpProxy();
		System.out.println(new SimpleWebBrowser().get("http://dealnews.com/rss/49-"));
	}
}
